package com.example.springboot_demo.demos.web.websocket_work.Mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.springboot_demo.demos.web.websocket_work.Pojo.MessageData;
import com.example.springboot_demo.demos.web.websocket_work.vo.MessageDataVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MessageMapper extends BaseMapper<MessageData> {
    //插入聊天室聊天记录
    @Override
    @Insert("insert into chat_history(content, chat_name, sender_name) values (#{content},#{chatName},#{senderName})")
    int insert(MessageData messageData);

    //查询聊天室
    @Select("select count(*) from chat_history where chat_name = #{key}")
    int selectChat(String key);

    //查询当前聊天记录
    @Select("select * from chat_history where chat_name = #{key}")
    List<MessageDataVo> selectChatByKey(String key);
}
